import requests

from com.yh.likeshop.utils.utils import like_host


class Addr():

    #获取详情地址
    def detail(self,id,token):
        addr = {"id":id}
        resp = requests.get(like_host+"/api/user_address/detail",params=addr,headers=token)
        return resp

    #将省市区名称转换成省市区id
    def handleregion(self,province,city,district,token):
        handle ={
        "province":province,
        "city":city,
        "district":district
        }
        resp = requests.post(like_host+"/api/user_address/handleregion",json=handle,headers=token)
        return resp

    #修改收货地址
    def update(self,id,contact,telephone,province_id,city_id,district_id,address,is_default,token):
        update = {
        "id":id,
        "contact":contact,
        "telephone":telephone,
        "province_id":province_id,
        "city_id":city_id,
        "district_id":district_id,
        "address":address,
        "is_default":is_default

        }
        resp = requests.post(like_host+"/api/user_address/update",json=update,headers=token)
        return resp

    #删除收货地址接口
    def del_list(self,id,token):
        del_list = {"id":id}
        requests.post(like_host+"/api/user_address/del",json=del_list,headers=token)
        return del_list

